<?php 
defined('RUN_KATANA') or die('Restricted access'); 
$StdPriceTxt = ucfirst($txt->getWord('price'));
$NowPriceTxt = ucfirst($txt->getWord($shop->getSetting('NowPriceTxt')));
$NoTaxTxt	 = $txt->getWord($shop->getSetting('NoTaxLabel'));
if(($shop->getSetting('user_level_prices') == 0) || ($shop->getSetting('user_level_prices') <= $user->getLevel()))
{
	if($shop->getSetting('now_price'))
	{
		unset($nowPriceEnd);
		unset($stdPrice);
		unset($nowPrice);
		$stdPriceClass = '';
		$nowPriceClass = '';
		
		$nowPriceEnd = $shop->CurrentProduct->Variations[$shop->CurrentProduct->getCurrentVariationId()]->getNowPriceDateEnd();
		if(strtotime($nowPriceEnd) > time())
		{
			$stdPrice = $shop->CurrentProduct->Variations[$shop->CurrentProduct->getCurrentVariationId()]->getStdPrice(true, 1, true);
			$nowPrice = $shop->CurrentProduct->Variations[$shop->CurrentProduct->getCurrentVariationId()]->getNowPrice(true, 1, true);
			if(intval($stdPrice) > intval($nowPrice))
			{
				$stdPriceClass = $shop->getSetting('NowPriceClassStd'); 
				$nowPriceClass = $shop->getSetting('NowPriceClass'); 
				$StdPriceTxt = ucfirst($txt->getWord($shop->getSetting('NowPriceTxtStd')));
			}
			else
			{
				unset($nowPriceEnd);
				unset($stdPrice);
				unset($nowPrice);
			}
		}
	}
	$AddCount = 1;
	$MinCount = 1;
	if($shop->getSetting('buy_min'))
	{
		if($shop->CurrentProduct->Variations[$shop->CurrentProduct->getCurrentVariationId()]->getBuyMin() > 1)
		{ $AddCount = $shop->CurrentProduct->Variations[$shop->CurrentProduct->getCurrentVariationId()]->getBuyMin(); }
	}
	$MinCount = $AddCount;
	?>
	<div class="prices">
		<span class="price variation_1 <?php echo $stdPriceClass; ?>">
			<strong><?php echo $StdPriceTxt; ?>:&nbsp;kr.&nbsp;<?php echo $shop->CurrentProduct->Variations[$shop->CurrentProduct->getCurrentVariationId()]->getStdPrice($shop->getSetting('tax_included_prices'), 1, true); ?><?php echo $shop->getSetting('MoneyFormatTail') ?></strong>
		</span>
		<span class="NoTaxTxt">&nbsp;<?php echo ' '.$NoTaxTxt;  ?></span>
		<?php if($nowPrice):  ?><br />
		<span>
			<strong class="price priceNow <?php echo $nowPriceClass; ?>"><?php echo $NowPriceTxt; ?> :&nbsp;kr.&nbsp;<?php echo $shop->CurrentProduct->Variations[$shop->CurrentProduct->getCurrentVariationId()]->getNowPrice($shop->getSetting('tax_included_prices'), 1, true); ?><?php echo $shop->getSetting('MoneyFormatTail') ?></strong>
		</span>
		<span class="NoTaxTxt">&nbsp;<?php echo ' '.$NoTaxTxt;  ?></span>
		<?php endif; ?>
		<div class="buy"><br />
			<form id="add_to_cart_<?php echo $shop->CurrentProduct->getId(); ?>" class="add_to_cart_form" name="add_to_cart_form" action="" method="post">
				<div>
					<input type="hidden" name="product" value="<?php echo $shop->CurrentProduct->getId(); ?>" />
					<input type="hidden" name="product_title" value="<?php echo $shop->CurrentProduct->getTitle(); ?>" />
					<input type="hidden" name="variation" value="<?php echo $shop->CurrentProduct->getCurrentVariationId(); ?>" class="variation" />
					<input type="hidden" name="action" value="add_to_cart" />
					<?php 
					if(count($shop->CurrentProduct->getAttributesVar()) > 0)
					{
						foreach($shop->CurrentProduct->getAttributesVar() as $att)
						{
							?>
							<input type="hidden" name="attribute_<?php echo $att['id']; ?>_value" value="<?php echo $shop->CurrentProduct->Variations[$shop->CurrentProduct->getCurrentVariationId()]->getAttributeValueId($att['id']); ?>" id="attribute_<?php echo $att['id']; ?>_value" />
							<?php 
							if($att['val_types'] == 5)
							{
								if($att['type'] == 4)
								{ 
									?>
									<input type="hidden" name="attribute_<?php echo $att['id']; ?>_value_cart" value="<?php echo $_POST['a_'.$att['id'].'_v_input'] ?>" id="attribute_<?php echo $att['id']; ?>_value_cart" />
									<?php
								}
							}
						}
					}
					?>
					<div class="add-to-cart">
						<?php 
							$button[0]['title']=ucfirst($txt->getWord('add_to_cart'));
							$button[0]['onclick']='document.getElementById(\'add_to_cart_'.$shop->CurrentProduct->getId().'\').submit();';
							$button[0]['params']['class'] = 'btn '.$shop->getSetting('detail_cart_btn');
							$button[0]['params']['icon'] = 'fa fa-shopping-cart icon-white';
						?>
						<?php if($shop->CurrentProduct->getGroupId() == 3): ?>
							<?php echo ucfirst($txt->getWord('count')); ?>:
							<input type="text" name="items_count" class="numeric xxsmall" value="<?php echo $AddCount; ?>" min="<?php echo $MinCount; ?>" onclick="this.value='';" />
						<?php else:  ?>
							<?php if($shop->getSetting('show_cart_add_count')): ?>
								<div class="input-group">
									<span class="input-group-addon"><?php echo ucfirst($txt->getWord('count')); ?>:</span>
									<?php if($MinCount > 1): ?>
									<select name="items_count" class="form-control" required>
										<?php  
										for($i = 1; $i < 20; $i++)
										{
											echo '<option value="'.($i*$MinCount).'">'.($i*$MinCount).'</option>';
										}
										?>
									</select>
									<?php else: ?>
									<input type="text" name="items_count" min="<?php echo $MinCount; ?>" required class="form-control" value="<?php echo $AddCount; ?>" />
									<?php endif;  ?>
									<span class="input-group-addon"><?php echo $shop->CurrentProduct->getStockUnit(); ?>.</span>
								</div><br />
								<?php echo getButtonsHTML($theme->HFBSets[$theme->HFB]['button'], $button, 1); ?>
							<?php else: ?>
								<input type="hidden" name="items_count" value="<?php echo $MinCount; ?>" />
							<?php endif;  ?>
						<?php endif;  ?>
						<?php 
						if(!$shop->getSetting('show_cart_add_count'))
						{ echo getButtonsHTML($theme->HFBSets[$theme->HFB]['button'], $button, 1); }
						?>
					</div>
				</div>
			</form>
			<?php if(count($cart->Items) > 0): ?>
				<div class="clear clearfix"></div><hr />
				<?php 
					if(count($cart->Items) > 0)
					{
						$button[0]['title']= ucfirst($txt->getWord('proceed_to_checkout'));
						$button[0]['href']='/m/'.$_GET['m'].'/?c=16';
						$button[0]['params']['icon'] = 'fa fa-credit-card';
						$button[0]['params']['class'] = 'btn btn-mini btn-sm btn-success btn-block small';
						echo getButtonsHTML(21, $button, 1);
						unset($button);
						
						$button[0]['title']= ucfirst($txt->getWord('continue_shopping'));
						$button[0]['href']='/';
						$button[0]['params']['class'] = 'btn btn-default btn-mini btn-sm btn-block small';
						$button[0]['params']['icon'] = 'fa fa-chevron-left';
						if($shop->CurrentProduct->getSectionId() > 0)
						{ $button[0]['href'] .= 'm/'.$shop->CurrentProduct->getSectionId().'/' ; }
						echo getButtonsHTML(21, $button, 1);
						unset($button);
					}
				?>
		<?php endif; ?>
		<br /><br />
	</div>
<?php
}
?>